package org.tourism.VO;

import lombok.Data;
import org.modelmapper.ModelMapper;
import org.modelmapper.TypeToken;
import org.tourism.entity.Complaint;

import java.lang.reflect.Type;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Data
public class ComplaintVO {
    private int id;
    private String content;
    private String category;
    private LocalDateTime dateTime;
    private boolean processStatus;
    private int reviewStatus;
    private UserVO userVO;
    private String attachment;

    public ComplaintVO() {
        this.processStatus = false;
        this.reviewStatus = 0;
    }

    public Complaint toEntity(){
        Complaint complaint = new Complaint();
        ModelMapper modelMapper = new ModelMapper();
        modelMapper.map(this, complaint);
        return complaint;
    }

    public static ComplaintVO toVO(Complaint complaint){
        ComplaintVO complaintVO = new ComplaintVO();
        ModelMapper modelMapper = new ModelMapper();
        modelMapper.map(complaint, complaintVO);
        return complaintVO;
    }

    public static List<ComplaintVO> toVOList(List<Complaint> complaints){
        ModelMapper modelMapper = new ModelMapper();
        List<ComplaintVO> complaintVOs = new ArrayList<>();
        Type listType = new TypeToken<List<ComplaintVO>>() {}.getType();
        return modelMapper.map(complaints, listType);
    }
}
